package graph2.weight.dijkstra;

import graph.weight.SparseWeightGraph;
import graph2.weight.ReadWeightGraph;
import graph2.weight.WeightedGraph;
import graph2.weight.WeightedSparseGraph;

/**
 * @Author yuh
 * @Date Created in 上午10:52 2018/4/1
 * @Description
 */
public class Main {

    // 测试我们的Bellman-Ford最短路径算法
    public static void main(String[] args) {

        String filename = "testG2.txt";
        //String filename = "testG_negative_circle.txt";
        int V = 250;

        WeightedGraph g = new WeightedSparseGraph(V, true);
        graph2.weight.ReadWeightGraph readGraph = new graph2.weight.ReadWeightGraph(g, filename);

        System.out.println("Test Bellman-Ford:\n");
        Dijkstra<Integer> bellmanFord = new Dijkstra<Integer>(g, 0);

            for (int i = 1; i < V; i++) {
                if (bellmanFord.hasPath(i)) {
                    System.out.println("Shortest Path to " + i + " : ");
                    bellmanFord.showPath(i);
                } else
                    System.out.println("No Path to " + i);

                System.out.println("----------");
            }

    }

}
